<template>
    <div style="width: 100%; height: 100%">
        <router-view></router-view>
        <el-breadcrumb
            separator-class="el-icon-arrow-right"
            class="breadcrumb-base"
            style="line-height: 30px"
        >
            <el-breadcrumb-item :to="{ path: '/institution/user' }">
                <i class="el-icon-user"></i>
                用户信息
            </el-breadcrumb-item>
        </el-breadcrumb>
        <div class="filter main-container">
            <div class="inner">
                <el-form
                    label-width="80px"
                    @submit.native.prevent
                >
                    <el-row>
                        <el-col :span="4">
                            <el-form-item label-width="20px">
                                <el-checkbox-group
                                    v-model="renzhengByChecked"
                                    size="mini"
                                >
                                    <el-checkbox-button
                                        v-for="item in renzhengGroup"
                                        :label="item"
                                        :key="item"
                                    >{{ item }}
                                    </el-checkbox-button>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="10">
                            <el-form-item label="关键字">
                                <el-input
                                    @keyup.13.native="btnSearch"
                                    size="mini"
                                    placeholder="请输入姓名"
                                    v-model="searchStringName"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-button
                                type="primary"
                                size="mini"
                                style="margin-right: 0px; float: right"
                                @click="jumpUserAdd"
                            >新增用户
                            </el-button>
                            <el-button
                                type="primary"
                                size="mini"
                                @click="btnSearch"
                                style="
                                    margin-left: 13px;
                                    margin-right: 13px;
                                    float: right;
                                "
                            >
                                搜索
                            </el-button>
                            <div
                                class="expansion"
                                @click="chickUnfold"
                                style="width: 100%"
                            >
                                <font-awesome-icon
                                    :icon="['fas', 'angle-down']"
                                    v-if="!showMoreSearchFilter"
                                    style="float: right"
                                >
                                </font-awesome-icon>
                                <font-awesome-icon
                                    :icon="['fas', 'angle-up']"
                                    v-else
                                    style="float: right"
                                ></font-awesome-icon>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            <el-form-item label="角色">
                                <el-checkbox-group
                                    size="mini"
                                    style="height: 40px"
                                    v-model="checkedCharacter"
                                >
                                    <el-checkbox
                                        v-for="identity in userGroupsList"
                                        :label="identity.id"
                                        :key="identity.id"
                                        style="float: left"
                                    >{{ identity.name }}
                                    </el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
            <!-- 扩展删选 -->
            <div
                class="inner"
                scoped
                v-if="showMoreSearchFilter"
            >
                <el-form label-width="80px">
                    <el-row>
                        <el-col
                            :span="12"
                            class="flat"
                        >
                            <el-form-item label="注册时间">
                                <el-date-picker
                                    size="mini"
                                    v-model="createdRange"
                                    type="daterange"
                                    range-separator="-"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col
                            :span="8"
                            class="flat"
                        >
                            <el-form-item label="用户状态">
                                <el-checkbox-group
                                    style="height: 40px"
                                    v-model="checkedStatus"
                                >
                                    <el-checkbox
                                        v-for="userStatus in userStatusList"
                                        :label="userStatus.value"
                                        :key="userStatus.value"
                                    >{{ userStatus.label }}
                                    </el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col
                            :span="12"
                            class="flat"
                        >
                            <el-form-item label="职级">
                                <el-select
                                    style="width: 350px; line-height: 28px"
                                    size="mini"
                                    v-model="positionSelect"
                                    multiple
                                    placeholder="请选择"
                                >
                                    <el-option
                                        v-for="t in postKindData"
                                        :key="t.dicCode"
                                        :label="t.dicName"
                                        :value="t.dicCode"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col
                            :span="12"
                            class="flat"
                        >
                            <el-form-item label="职称">
                                <el-select
                                    style="width: 350px; line-height: 28px"
                                    size="mini"
                                    v-model="jobtitleSelect"
                                    multiple
                                    placeholder="请选择"
                                >
                                    <el-option
                                        v-for="t in titleData"
                                        :key="t.id"
                                        :label="t.dicName"
                                        :value="t.dicCode"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col
                            :span="12"
                            class="flat"
                        >
                            <el-form-item label="所属区域">
                                <el-cascader
                                    style="width: 350px; line-height: 28px"
                                    size="mini"
                                    :props="props"
                                    :options="areaOptionsData"
                                    v-model="areaSelect"
                                    clearable
                                    placeholder="请选择搜索的区域"
                                >
                                </el-cascader>
                            </el-form-item>
                        </el-col>
                        <el-col>
                            <el-form-item label="诊断组">
                                <el-checkbox-group
                                    size="mini"
                                    style="height: 40px"
                                    v-model="checkedsubGroups"
                                >
                                    <el-checkbox
                                        v-for="s in subGroupsData"
                                        style="float: left"
                                        :label="s.id"
                                        :value="s.id"
                                        :key="s.id"
                                    >
                                        {{ s.name }}
                                    </el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
            <!-- 列表数据 -->
            <div>
                <el-row class="interval">
                    <base-table
                        v-loading="waitingloaded"
                        ref="templateTable"
                        :data="templateTable.data"
                        :header="templateTable.header"
                        :pageInfo="templateTable.pageInfo"
                        :cellStyleFunc="templateTableCellStyleFunc"
                        :buttonVisibleFunc="templateTableButtonVisibleFunc"
                        @handleClick="templateTableButtonClick"
                        @pageJumpTo="pageJumpTo"
                        @sizeChange="pagesizeChange"
                    >
                    </base-table>
                </el-row>
            </div>
        </div>
        <el-dialog
            title="重置密码"
            :visible.sync="centerDialogVisible"
            width="30%"
            center
        >
            <el-row>
                <el-col :span="4">重置密码为:</el-col>
                <el-col :span="20">
                    <el-input
                        size="mini"
                        placeholder="请输入新密码"
                        v-model="newPassword"
                    ></el-input>
                </el-col>
            </el-row>
            <span
                slot="footer"
                class="dialog-footer"
            >
                <el-button
                    size="mini"
                    @click="centerDialogVisible = false"
                >取 消</el-button>
                <el-button
                    size="mini"
                    type="primary"
                    @click="resetPwd"
                >确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import moment from 'moment';
import BaseTable from '@templates/components/BaseTable';
import _ from 'lodash';
import { itemsPerPage } from '@/client/libs/util';

export default {
    name: 'users-list',
    components: {
        BaseTable,
    },
    data() {
        return {
            centerDialogVisible: false,
            newPassword: '',
            resetPwdId: '',
            templateTable: {
                data: [],
                header: [
                    {
                        prop: 'name',
                        label: '姓名',
                        width: '110',
                    },
                    {
                        prop: 'name',
                        label: '操作',
                        fixed: true,
                        width: '280',
                        isRender: true,
                        render: (h, params) => {
                            const _vm = this;
                            const props = {
                                type: 'text',
                                disabled: false,
                                size: 'small',
                                circle: 'circle',
                            };
                            const staticStyle = {
                                margin: '0 5px',
                            };
                            return h('div', [
                                params.row.status === '正常'
                                    ? h('span', [
                                          h(
                                              'el-button',
                                              {
                                                  props: {
                                                      ...props,
                                                      disabled:
                                                          params.row.id === 1,
                                                  },
                                                  on: {
                                                      click: function ($event) {
                                                          return _vm.userfroozen(
                                                              params.row
                                                          );
                                                      },
                                                  },
                                                  staticStyle: {
                                                      ...staticStyle,
                                                  },
                                              },
                                              '冻结'
                                          ),
                                      ])
                                    : h('span', [
                                          h(
                                              'el-button',
                                              {
                                                  props: {
                                                      ...props,
                                                      disabled:
                                                          params.row.id === 1,
                                                  },
                                                  on: {
                                                      click: function ($event) {
                                                          return _vm.userunfroozen(
                                                              params.row
                                                          );
                                                      },
                                                  },
                                                  staticStyle: {
                                                      ...staticStyle,
                                                  },
                                              },
                                              '解冻'
                                          ),
                                      ]),
                                h('span', [
                                    h(
                                        'el-button',
                                        {
                                            props: { ...props },
                                            on: {
                                                click: function ($event) {
                                                    return _vm.resetToken(
                                                        params.row
                                                    );
                                                },
                                            },
                                            staticStyle: { ...staticStyle },
                                        },
                                        '重置登录'
                                    ),
                                ]),

                                h('span', [
                                    h(
                                        'el-button',
                                        {
                                            props: {
                                                ...props,
                                                disabled: params.row.id === 1,
                                            },
                                            on: {
                                                click: function ($event) {
                                                    return _vm.tableOptionServiceMag(
                                                        params.row
                                                    );
                                                },
                                            },
                                            staticStyle: {
                                                ...staticStyle,
                                                color:
                                                    params.row.id === 1
                                                        ? ''
                                                        : 'red',
                                            },
                                        },
                                        '管理'
                                    ),
                                ]),
                                h('span', [
                                    h(
                                        'el-button',
                                        {
                                            props: { ...props },
                                            on: {
                                                click: function ($event) {
                                                    return _vm.tableOptionResetPwd(
                                                        params.row
                                                    );
                                                },
                                            },
                                            staticStyle: { ...staticStyle },
                                        },
                                        '重置密码'
                                    ),
                                ]),
                            ]);
                        },
                    },
                    {
                        prop: 'jobNumber',
                        label: '工号',
                        width: '80',
                    },
                    {
                        prop: 'roleVoList',
                        label: '角色',
                        width: '100',
                    },
                    {
                        prop: 'status',
                        label: '用户状态',
                        width: '107',
                    },
                    {
                        prop: 'diagnosisPermissionVoList',
                        label: '诊断组',
                        width: '250',
                    },
                    {
                        prop: 'genderName',
                        label: '性别',
                        width: '80',
                    },

                    {
                        prop: 'positionName',
                        label: '职级',
                        width: '80',
                    },
                    {
                        prop: 'medicalTitleName',
                        label: '职称',
                        width: '80',
                    },
                    {
                        prop: 'createTime',
                        label: '注册时间',
                        width: '107',
                    },
                    {
                        prop: 'address',
                        label: '所在地',
                        width: '204',
                    },
                    {
                        label: '实名认证',
                        prop: 'idCardStatus',
                        width: '107',
                        isButton: true,
                        functionKey: 'showIDCardDialog',
                    },
                    {
                        label: '资质认证',
                        prop: 'qualityStatus',
                        width: '107',
                        isButton: true,
                        functionKey: 'showQualificationDialog',
                    },
                ],
                pageInfo: {
                    size: itemsPerPage.get(),
                    page: 1,
                    total: 0,
                },
            },
            // 分页信息
            totalCount: 0,
            // 匹配查询
            searchFilter: {},
            // 查询关键字 只能查名字
            searchStringName: '',
            // '实名认证', '资质认证'的model,根据接口还要转换
            renzhengByChecked: [],
            renzhengGroup: ['实名认证', '资质认证'],
            // 角色列表
            userGroupsList: [],
            // 确定了的角色ID
            checkedCharacter: [],
            checkAllCharacter: [],
            // 职称
            titleData: [],
            // 选择了的职称
            jobtitleSelect: [],
            // 职级
            postKindData: [],
            // 选择了的职级
            positionSelect: [],
            // 诊断数据列表
            subGroupsData: [],
            // 确定的诊断数据
            checkedsubGroups: [],
            // 全部机构列表
            hospitalNameList: [],
            // 用户状态列表
            userStatusList: [
                {
                    label: '正常',
                    value: 0,
                },
                {
                    label: '冻结',
                    value: 1,
                },
            ],
            // 确定了的用户状态
            checkedStatus: [0],
            // 确定了的时间区域
            createdRange: [],
            // 搜索的地区数据
            areaOptionsData: [],
            props: {
                value: 'id',
                label: 'name',
                children: 'childrenList',
            },
            // 确定了的地区区域,根据接口的要求，搜索的时候还要
            // 转换数组为3个对象
            areaSelect: [],
            waitingloaded: false,
            pickerOptions: {
                disabledDate(time) {
                    const date = new Date();
                    date.setMonth(date.getMonth() - 1);
                    if (
                        time.getTime() > Date.now() ||
                        time.getTime() < date.getTime()
                    ) {
                        return true;
                    }
                    return false;
                },
            },
            showMoreSearchFilter: false,
        };
    },
    computed: {},
    mounted() {
        // 数据初始化
        // 查找职级
        this.getPostKind();
        // 查找职称
        this.getTitleForClinic();
        // 获取用户的数据列表
        this.getListData({
            page: this.templateTable.pageInfo.page - 1,
            size: this.templateTable.pageInfo.size,
            institutionId: this.$store.state.institution.id,
            statusList: [0],
        });
        // 获取角色列表
        this.getuserGroupsList();
        // 获取诊断数据列表
        this.getsubGroupsDataList();
        // 行政区域数据初始化
        this.getareaOptionsData();
    },
    methods: {
        templateTableCellStyleFunc({ row, column }) {
            const baseStyle = {
                padding: '3px 0',
                'border-right': '1px solid #ffffff',
                'font-size': '14px',
            };
            if (column.label === '状态') {
                if (row.status === 1) {
                    baseStyle.color = 'red';
                }
                if (row.status === 0) {
                    baseStyle.color = '#409eff';
                }
            }
            return baseStyle;
        },
        templateTableButtonVisibleFunc(key, row) {
            switch (key) {
                case 'userfroozen':
                    return row.status === '正常';
                case 'userunfroozen':
                    return row.status === '冻结';
                default:
                    return true;
            }
        },
        templateTableButtonClick(functionKey, row) {
            this[functionKey](row);
        },
        // 获取字典职级数据
        getPostKind() {
            try {
                this.$axios({
                    method: 'get',
                    url: '/PROXY-Remote/dicts/list',
                    params: {
                        code: 'PostKind',
                    },
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        res.data.data.forEach((element) => {
                            this.postKindData.push({
                                dicName: element.name,
                                dicCode: element.id,
                            });
                        });
                    }
                });
            } catch (e) {
                console.log('请求失败');
            }
        },
        // 查找字典职称数据
        getTitleForClinic() {
            try {
                this.$axios({
                    method: 'get',
                    url: '/PROXY-Remote/dicts/list',
                    params: {
                        code: 'TitleForClinic',
                    },
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        res.data.data.forEach((element) => {
                            this.titleData.push({
                                dicName: element.name,
                                dicCode: element.id,
                            });
                        });
                    }
                });
            } catch (e) {
                console.log('请求失败');
            }
        },
        // 获取角色列表
        getuserGroupsList() {
            try {
                this.$axios({
                    method: 'get',
                    url: '/PROXY-Remote/roles',
                    params: {},
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        res.data.data.forEach((element) => {
                            this.userGroupsList.push({
                                id: element.id,
                                name: element.name,
                            });
                        });
                    }
                });
            } catch (e) {
                console.log('请求失败');
            }
        },
        // 获取诊断数据列表
        getsubGroupsDataList() {
            try {
                this.$axios({
                    method: 'get',
                    url: '/PROXY-Remote/subgroups',
                    params: {},
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        res.data.data.forEach((element) => {
                            this.subGroupsData.push({
                                id: element.id,
                                name: element.name,
                            });
                        });
                    }
                });
            } catch (e) {
                console.log('请求失败');
            }
        },
        // 获取行政区域数据
        getareaOptionsData() {
            try {
                this.$axios({
                    method: 'get',
                    url: '/PROXY-Remote/provinces',
                    params: {},
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        this.areaOptionsData = res.data.data;
                    }
                });
            } catch (e) {
                console.log('请求失败');
            }
        },
        // 获取列表数据
        getListData(filter) {
            try {
                this.waitingloaded = true;
                this.$axios({
                    method: 'post',
                    url: '/PROXY-Remote/users/search',
                    data: filter,
                    headers: {
                        'Content-Type': 'application/json',
                    },
                }).then((res) => {
                    if (res && res.data.code === 200) {
                        // 数据处理
                        this.templateTable.data = [];
                        res.data.data.forEach((ele) => {
                            const Temp = ele;
                            // Assignment to property of function parameter 'ele'  no-param-reassign
                            Temp.diagnosisPermissionVoList = this.doSubGroups(
                                ele.diagnosisPermissionVoList
                            );

                            Temp.createTime = ele.createTime
                                ? moment(ele.createTime).format('YYYY-MM-DD')
                                : '';
                            Temp.roleVoList = this.doRoles(ele.roleVoList);

                            Temp.address =
                                `${
                                    ele.provinceName === null
                                        ? ''
                                        : `${ele.provinceName}-`
                                }` +
                                `${
                                    ele.cityName === null
                                        ? ''
                                        : `${ele.cityName}-`
                                }` +
                                `${
                                    ele.countyName === null
                                        ? ''
                                        : ele.countyName
                                }`;

                            Temp.status = ele.status === 0 ? '正常' : '冻结';
                            Temp.idCardStatus =
                                ele.idCardStatus === 0 ? '已通过' : '未通过';
                            Temp.qualityStatus =
                                ele.qualityStatus === 0 ? '已通过' : '未通过';
                            this.templateTable.data.push(Temp);
                        });
                        this.waitingloaded = false;
                        this.totalCount = res.data.pageInfo.total;
                        this.templateTable.pageInfo = {
                            total: res.data.pageInfo.total,
                            page: res.data.pageInfo.page + 1,
                            size: res.data.pageInfo.size,
                        };
                    }
                });
            } catch (e) {
                this.waitingloaded = false;
                this.$message.info('请求失败');
            }
        },
        // 处理列表栏诊断组数据
        doSubGroups(SubGroups) {
            let doSubGroupsData = '';
            let chuzhen = [];
            let hefa = [];
            let shenhe = [];
            let zhongshen = [];
            SubGroups.forEach((ele) => {
                ele.diagnosisLevelVoList.forEach((temp) => {
                    if (temp.level === 2) {
                        chuzhen.push(ele.subgroupName);
                    }
                    if (temp.level === 3) {
                        hefa.push(ele.subgroupName);
                    }
                    if (temp.level === 4) {
                        shenhe.push(ele.subgroupName);
                    }
                    if (temp.level === 5) {
                        zhongshen.push(ele.subgroupName);
                    }
                });
            });
            chuzhen = _.uniq(chuzhen);
            hefa = _.uniq(hefa);
            shenhe = _.uniq(shenhe);
            zhongshen = _.uniq(zhongshen);
            if (chuzhen.length > 0) {
                let data = '';
                chuzhen.forEach((tep) => {
                    data += tep === '' ? '' : `${tep} `;
                });
                doSubGroupsData += `<div style="text-align:left;width:100%"><span style="color:red;font-size:12px;">初诊:</span><span style="font-size:12px">${data}</span></div>`;
            }
            if (hefa.length > 0) {
                let data = '';
                hefa.forEach((tep) => {
                    data += tep === '' ? '' : `${tep} `;
                });
                doSubGroupsData += `<div style="text-align:left;width:100%"><span style="color:red;font-size:12px;">核发:</span><span style="font-size:12px">${data}</span></div>`;
            }
            if (shenhe.length > 0) {
                let data = '';
                shenhe.forEach((tep) => {
                    data += tep === '' ? '' : `${tep} `;
                });
                doSubGroupsData += `<div style="text-align:left;width:100%"><span style="color:red;font-size:12px;">审核:</span><span style="font-size:12px">${data}</span></div>`;
            }
            if (zhongshen.length > 0) {
                let data = '';
                zhongshen.forEach((tep) => {
                    data += tep === '' ? '' : `${tep} `;
                });
                doSubGroupsData += `<div style="text-align:left;width:100%"><span style="color:red;font-size:12px;">终审:</span><span style="font-size:12px">${data}</span></div>`;
            }

            return doSubGroupsData;
        },
        // 处理列表角色栏数据
        doRoles(roleVoList) {
            let rolesName = '';
            roleVoList.forEach((ele) => {
                rolesName += `${ele.roleName}\n`;
            });
            return rolesName;
        },
        jumpUserAdd() {
            this.$router.push('/institution/user/add');
        },
        tableOptionServiceMag(user) {
            this.$store.commit('setPropertyGeneral', {
                key: 'userID',
                value: user.id,
            });
            this.$router.push('/institution/user/info');
        },
        // 分页调转
        pageJumpTo(val) {
            this.templateTable.pageInfo.page = val;
            let filter = {
                page: this.templateTable.pageInfo.page - 1,
                size: this.templateTable.pageInfo.size,
                institutionId: this.$store.state.institution.id,
            };
            if (this.checkedsubGroups.length > 0) {
                filter.subgroupIdList = this.checkedsubGroups;
            }
            // 获取用户的数据列表
            this.getListData(filter);
        },
        // 分页调转
        pagesizeChange(val) {
            this.templateTable.pageInfo.size = val;
            // 获取用户的数据列表
            this.getListData({
                page: this.templateTable.pageInfo.page - 1,
                size: this.templateTable.pageInfo.size,
                institutionId: this.$store.state.institution.id,
            });
        },
        userfroozen(val) {
            // 用户冻结
            this.$confirm(
                '是否冻结该用户？点击确认继续，点击取消退出',
                '提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }
            ).then(() => {
                try {
                    this.$axios({
                        method: 'PUT',
                        url: `/PROXY-Remote/users/lock/${val.id}`,
                    }).then((res) => {
                        if (res.data.code === 200) {
                            this.getListData({
                                page: this.templateTable.pageInfo.page - 1,
                                size: this.templateTable.pageInfo.size,
                                institutionId: this.$store.state.institution.id,
                            });
                        }
                    });
                } catch (e) {
                    console.log('请求失败');
                }
            });
        },
        userunfroozen(val) {
            this.$confirm(
                '是否解冻该用户？点击确认继续，点击取消退出',
                '提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }
            ).then(() => {
                try {
                    this.$axios({
                        method: 'PUT',
                        url: `/PROXY-Remote/users/unlock/${val.id}`,
                    }).then((res) => {
                        if (res.data.code === 200) {
                            this.getListData({
                                page: this.templateTable.pageInfo.page - 1,
                                size: this.templateTable.pageInfo.size,
                                institutionId: this.$store.state.institution.id,
                            });
                        }
                    });
                } catch (e) {
                    console.log('请求失败');
                }
            });
        },
        resetToken(val) {
            this.$confirm('会重置登录状态，是否继续？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                try {
                    this.$axios({
                        method: 'GET',
                        url: `/PROXY-Remote/login/reset/token/${val.id}`,
                    }).then((res) => {
                        if (res.data.code === 200) {
                            this.$message.info('重置成功！');
                        }
                    });
                } catch (e) {
                    console.log('请求失败');
                }
            });
        },
        tableOptionResetPwd(val) {
            this.newPassword === '';
            this.centerDialogVisible = true;
            this.resetPwdId = val.id;
        },
        resetPwd() {
            if (this.newPassword === '') {
                this.$message.warning('重置密码不能为空!');
            } else {
                this.$axios({
                    method: 'PUT',
                    url: `/PROXY-Remote/reset-password/${this.resetPwdId}/${this.newPassword}`,
                }).then((res) => {
                    if (res.data.code === 200) {
                        this.centerDialogVisible = false;
                        const tipsInfo = `重置密码成功!     重置密码为${res.data.data.defaultPassWord}`;
                        this.$message.info(tipsInfo);
                    }
                });
            }
        },
        showIDCardDialog() {
            // todo
        },
        showQualificationDialog() {},
        chickUnfold() {
            this.showMoreSearchFilter = !this.showMoreSearchFilter;
        },
        btnSearch() {
            // 条件查询
            // 接口请求数据接口格式
            //  {
            //       "cityId": 0,
            //       "countyId": 0,
            //       "createTimeEnd": "",
            //       "createTimeStart": "",
            //       "idCardStatus": 0,
            //       "institutionId": 0,
            //       "medicalTitleList": [
            //         0
            //       ],
            //       "name": "string",
            //       "page": 0,
            //       "positionList": [
            //         0
            //       ],
            //       "provinceId": 0,
            //       "qualityStatus": 0,
            //       "roleIdList": [
            //         0
            //       ],
            //         "statusList": [],
            //       "status": 0,
            //       "subgroupIdList": [
            //         0
            //       ]
            //     }
            // 按照接口返回数据格式定义对象
            const tempFilter = {};
            // 实名认证 资质认认证
            this.renzhengByChecked.forEach((ele) => {
                if (ele === '实名认证') {
                    tempFilter.idCardStatus = 1;
                }
                if (ele === '资质认证') {
                    tempFilter.qualityStatus = 1;
                }
            });
            // 关键字姓名查询
            if (this.searchStringName) {
                tempFilter.name = this.searchStringName;
            }
            // 角色ID 数组
            if (this.checkedCharacter.length > 0) {
                tempFilter.roleIdList = this.checkedCharacter;
            }

            // 确定了的时间范围
            if (this.createdRange && this.createdRange.length > 0) {
                let createTimeStart = '';
                let createTimeEnd = '';
                [createTimeStart, createTimeEnd] = this.createdRange;
                tempFilter.createTimeStart = moment(createTimeStart).format(
                    'YYYY-MM-DD HH:mm:ss'
                );
                tempFilter.createTimeEnd = moment(createTimeEnd).format(
                    'YYYY-MM-DD HH:mm:ss'
                );
            }
            // 确定用户状态TODO
            if (this.checkedStatus.length > 0) {
                console.log(this.checkedStatus);
                tempFilter.statusList = this.checkedStatus;
            }
            // 确定职级
            if (this.positionSelect.length > 0) {
                tempFilter.positionList = this.positionSelect;
            }
            // 确定职称
            if (this.jobtitleSelect.length > 0) {
                tempFilter.medicalTitleList = this.jobtitleSelect;
            }
            // 确定所属区域
            if (this.areaSelect.length > 0) {
                [
                    tempFilter.provinceId,
                    tempFilter.cityId,
                    tempFilter.countyId,
                ] = this.areaSelect;
            }
            // 诊断组
            if (this.checkedsubGroups.length > 0) {
                tempFilter.subgroupIdList = this.checkedsubGroups;
            }

            // 必须传入的参数
            tempFilter.page = this.templateTable.pageInfo.page - 1;
            tempFilter.size = this.templateTable.pageInfo.size;
            tempFilter.institutionId = this.$store.state.institution.id;
            console.log('tempFilter', tempFilter);
            this.getListData(tempFilter);
        },
    },
};
</script>

<style scoped>
.el-form-item {
    margin-bottom: 0px;
}
.filter {
    border-bottom: #f4f4f4 1px;
    /*padding: 20px;*/
    background: #ffffff;
}
.image {
    height: 234px;
    width: 416px;
    margin-left: 15px;
}
.header {
    margin-top: 20px;
    font-size: 14px;
}
.inner {
    border-bottom: #f4f4f4 1px;
    /*padding: 10px 20px 10px;*/
    background: #ffffff;
}
.row-inner .flat {
    height: 40px;
}
.interval {
    margin-top: 5px;
}
.reset-pwd-color {
    color: #f56c6c;
}
.dateRange {
    max-width: 280px;
}
.expansion {
    width: 30px;
    height: 30px;
    display: inline;
    font-size: 28px;
    line-height: 30px;
    margin-top: 25px;
    vertical-align: middle;
    color: #10a1df;
    cursor: pointer;
}
.el-table .cell {
    white-space: pre-line;
}
</style>
